package geppetto.phraseHMM.phraseExtraction.extractedphrase;

public class ExtractedPhrasePairTable {
	ExtractedPhrasePair[][][][] sourceTargetIndexPairs;
	ExtractedPhrasePair[][][][] targetSourceIndexPairs;	
	ExtractedPhrasePair[] extractedPhrasePairs;
	SentenceInfo info;
	
	public ExtractedPhrasePairTable(SentenceInfo info, ExtractedPhrasePair[] extractedPhrasePairs) {
		super();
		this.info = info;
		this.extractedPhrasePairs = extractedPhrasePairs;
		int sourceLen = info.getSourceSentence().length*2; 
		int targetLen = info.getForeingSentence().length*2;
		//sourceTargetIndexPairs = new ExtractedPhrasePair[sourceLen][sourceLen][targetLen][targetLen];
		//targetSourceIndexPairs = new ExtractedPhrasePair[targetLen][targetLen][sourceLen][sourceLen];
		/*for(ExtractedPhrasePair epp : extractedPhrasePairs){
			insertExtractedPhrasePair(epp);
		}*/
	}

	public void insertExtractedPhrasePair(ExtractedPhrasePair epp){
		insertExtractedPhrasePairSourceTarget(epp);
		insertExtractedPhrasePairTargetSource(epp);
	}
	
	protected void insertExtractedPhrasePairSourceTarget(ExtractedPhrasePair epp){
		int sourceStartPos = epp.getSourceStartPos();
		int sourceEndPos = epp.getSourceEndPos();
		int targetStartPos = epp.getForeignStartPos();
		int targetEndPos = epp.getForeignEndPos();
		sourceTargetIndexPairs[sourceStartPos][sourceEndPos][targetStartPos][targetEndPos]=epp;
	}
	
	protected void insertExtractedPhrasePairTargetSource(ExtractedPhrasePair epp){
		int sourceStartPos = epp.getSourceStartPos();
		int sourceEndPos = epp.getSourceEndPos();
		int targetStartPos = epp.getForeignStartPos();
		int targetEndPos = epp.getForeignEndPos();
		targetSourceIndexPairs[targetStartPos][targetEndPos][sourceStartPos][sourceEndPos]=epp;
	}
	
	public ExtractedPhrasePair getExtractedPhrasePair(int sourceStart, int sourceEnd, int targetStart, int targetEnd){
		return sourceTargetIndexPairs[sourceStart][sourceEnd][targetStart][targetEnd];
	}

	public ExtractedPhrasePair[] getExtractedPhrasePairs() {
		return extractedPhrasePairs;
	}

	public ExtractedPhrasePair[][][][] getSourceTargetIndexPairs() {
		return sourceTargetIndexPairs;
	}
}
